package edu.nf.postlikework.controller;


import edu.nf.postlikework.result.ResultVo;
import org.springframework.http.HttpStatus;

/**
 * @author wangl
 * @date 2023/12/6
 */
public class BaseController {

    public <T> ResultVo<T> success(T data) {
        ResultVo<T> vo = new ResultVo<>();
        vo.setCode(HttpStatus.OK.value());
        vo.setData(data);
        return vo;
    }

    public ResultVo<?> success() {
        ResultVo<?> vo = new ResultVo<>();
        vo.setCode(HttpStatus.OK.value());
        return vo;
    }

    public ResultVo<?> error(int code, String message) {
        ResultVo<?> vo = new ResultVo<>();
        vo.setCode(code);
        vo.setMessage(message);
        return vo;
    }
}